<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>填写快递信息</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		
		$(document).ready(function(){
			
			$("#freight").keydown(function(e) {
				// 0 keyCode 48 9 keyCode 57 . keyCode 190 删除 keyCode 8
				let keyCode = e.keyCode;
				if(keyCode >= 48 && keyCode <= 57 || keyCode === 190 || keyCode === 8) {
				let num = ($("#freight").val() + "" + e.key);
				if(/^[0-9]+(.[0-9]{0,2})?$/.test(num)) {
				} else {
				if(e.keyCode === 8) {
					return;
				}
					e.preventDefault();
				}
				} else {
					e.preventDefault();
				}
				});
			
			$("#deliveryNumber").val();
			$("#deliveryName").val();
			$("#freight").val();
			$("#addForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
					parent.location.reload();
				　　window.close();
					$(".jbox-content", top.document).css("overflow-y","hidden");
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
</head>
<body>
    <ul class="nav nav-tabs">
		<li><a href="${ctx}/bu/buExternalOrder/">外部订单列表</a></li>
				<c:choose>
				   <c:when test="${flag eq 1 and write eq 0}">
				   		<shiro:hasPermission name="bu:buExternalOrder:operate:edit"><li class="active"><a href="${ctx}/bu/buExternalOrder/form?id=${buOrder.id}&flag=2&write=0">外部订单${not empty buOrder.id?'修改':'添加'}</a></li></shiro:hasPermission>
				   </c:when>
				   <c:when test="${flag eq 2 and write eq 0}">
				   		<shiro:hasPermission name="bu:buExternalOrder:view"><li class="active"><a href="${ctx}/bu/buExternalOrder/view?id=${buOrder.id}&flag=2&write=0">外部订单查看</a></li></shiro:hasPermission>
				   </c:when>
				   <c:when test="${flag eq 3 and write eq 0}">
				   		<shiro:hasPermission name="bu:buExternalOrder:operate:copy"><li class="active"><a href="${ctx}/bu/buExternalOrder/copy?id=${buOrder.id}&flag=1&write=0">外部订单复制</a></li></shiro:hasPermission>
				   </c:when>
				   <c:when test="${flag eq 1 and write eq 1}">
				   		<shiro:hasPermission name="bu:buExternalOrder:operate:delivery"><li class="active"><a href="${ctx}/bu/buExternalOrder/selectById?id=${buOrder.id}&flag=1&write=1">外部订单填写快递信息</a></li></shiro:hasPermission>
				   </c:when>
				</c:choose>
	</ul><br/>
	<form:form id="addForm" modelAttribute="buOrder" action="${ctx}/bu/buExternalOrder/updateDelivery?flag=6&write=1" method="post" class="form-horizontal">
		<form:hidden path="id" id="id" name="id" value="${id}"/>
		<form:hidden path="orderState" id="orderState" name="orderState" value="${orderState}"/>
		<div class="control-group">
			<label class="control-label">快递单号：</label>
			<div class="controls">
				<form:input path="deliveryNumber" htmlEscape="false" id="deliveryNumber" name="deliveryNumber" maxlength="64" class="required input-xlarge "/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">快递单名称：</label>
			<div class="controls">
				<form:input path="deliveryName" htmlEscape="false" id="deliveryName" name="deliveryName" maxlength="64" class="required input-xlarge "/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">运费：</label>
			<div class="controls">
				<form:input path="freight" htmlEscape="false" id="freight" name="freight" maxlength="64" class="required input-xlarge "/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="form-actions">
		   	<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>
